package com.litbw.publicobservable;

import com.litbw.user.User;

/**
 * LoginMessage should be sent to all observers, which will need to take action
 * or store a reference to the currently logged in User object, upon successful
 * authentication.
 * <BR><BR>
 * NOTE: Do not send a null User LoginMessage, instead use the marker message
 * LogoutMessage.
 * @author Michael Morris
 *
 */
public final class LoginMessage extends SimpleMessage {

	/**
	 * The user which has successfully logged in.
	 */
	private final User user;
	
	/**
	 * Create a new successful login message with the specified user.
	 * @param usr The User object to pass with this message.
	 */
	public LoginMessage(User usr) {
	
		super();
		
		if (usr == null)
			throw new IllegalArgumentException("cannot login without a valid user");
		
		user = usr;
		
	}
	
	/**
	 * Get the successfully logged in User reference.
	 * @return A User object.
	 */
	public final User getUser() {
		return user;
	}
	
}
